<?php
/**
 * Created by PhpStorm.
 * User: xutao
 * Date: 2018/8/8
 * Time: 13:41
 */
namespace app\index\controller;
use app\common\model\AdModel;
use app\common\model\BannerModel;
use app\common\model\BpModel;
class Article extends Base{
    //轮播图获取
    public function get_banner(){
        if(\request()->isPost()){
            /*
             * 1首页 2目的地 3攻略
             * */
            $type = input('type');
            $data = BannerModel::where('type',$type)->where('is_show',1)->order('sort desc')->select();
            return json(['code'=>200,'data'=>$data,'msg'=>'获取成功']);
        }else{
            return json(['code'=>0,'data'=>'','msg'=>'非法请求']);
        }
    }
    //广告获取
    public function get_ad(){
        if(request()->isPost()){
            $re = AdModel::where('is_show',1)->order('sort desc')->limit(4)->select();
            return json(['code'=>200,'data'=>$re,'msg'=>'获取成功']);
        }else{
            return json(['code'=>0,'data'=>'','msg'=>'非法请求']);
        }
    }
    //引导页面获取
    public function get_bp(){
        if(request()->isPost()){
            $re = BpModel::find();
            return json(['code'=>200,'data'=>$re,'msg'=>'获取成功']);
        }else{
            return json(['code'=>0,'data'=>'','msg'=>'非法请求']);
        }
    }

}